<cfcomponent extends="assets.calgrants.com.Base">

	<cfscript>
        import assets.calgrants.com.bo.Volunteer;
	</cfscript>
	
	<cffunction name="get" access="public" output="false" returntype="assets.calgrants.com.bo.Volunteer">
		<cfargument name="Volunteer_ID" type="numeric" required="true" />
		<cfscript>
			if (arguments.Volunteer_ID gt 0) {
				local.loadArgs = {};
				local.loadArgs.obj = new Volunteer();
				StructAppend(local.loadArgs, QueryToStruct(read(argumentCollection = arguments))[1]);
				return load(argumentCollection = local.loadArgs);
			} else {
				return new Volunteer();
			}
		</cfscript>
	</cffunction>
	
	<cffunction name="load" access="public" output="false" returntype="assets.calgrants.com.bo.Volunteer">
		<cfargument name="obj" type="assets.calgrants.com.bo.Volunteer" required="true" />
		<cfscript>
			local.obj = arguments.obj;
			if (IsDefined("arguments.Volunteer_ID")) {
				local.obj.setVolunteer_ID(arguments.Volunteer_ID);
			}
			if (IsDefined("arguments.Deleted")) {
				local.obj.setDeleted(arguments.Deleted);
			}
			if (IsDefined("arguments.Organization_ID")) {
				local.obj.setOrganization_ID(arguments.Organization_ID); 
			}
			if (IsDefined("arguments.Pool")) {
				local.obj.setDeleted(arguments.Deleted);
			}
			if (IsDefined("arguments.First_Name")) {
				local.obj.setFirst_Name(arguments.First_Name);
			}
			if (IsDefined("arguments.Last_Name")) {
				local.obj.setLast_Name(arguments.Last_Name);
			}
			if (IsDefined("arguments.Title")) {
				local.obj.setTitle(arguments.Title);
			}
			if (IsDefined("arguments.Organization")) {
				local.obj.setOrganization(arguments.Organization);
			}
			if (IsDefined("arguments.Address")) {                             
				local.obj.setAddress(arguments.Address);
			}
			if (IsDefined("arguments.City")) {
				local.obj.setCity(arguments.City);
			}
			if (IsDefined("arguments.Zip_Code")) {
				local.obj.setZip_Code(arguments.Zip_Code);
			}
			if (IsDefined("arguments.County_ID")) {
				local.obj.setCounty_ID(arguments.County_ID);
			}
			if (IsDefined("arguments.Phone")) {                             
				local.obj.setPhone(arguments.Phone);
			}
			if (IsDefined("arguments.Extension")) {                             
				local.obj.setExtension(arguments.Extension);
			}
			if (IsDefined("arguments.Email")) {
				local.obj.setEmail(arguments.Email);
			}
			if (IsDefined("arguments.Travel_Distance")) {
				local.obj.setTravel_Distance(arguments.Travel_Distance);
			}
			if (IsDefined("arguments.Financial_Aid_Expert")) {
				local.obj.setFinancial_Aid_Expert(arguments.Financial_Aid_Expert);
			}
			if (IsDefined("arguments.FAFSA_Expert")) {
				local.obj.setFAFSA_Expert(arguments.FAFSA_Expert);
			}
			if (IsDefined("arguments.Finance_Expert")) {
				local.obj.setFinance_Expert(arguments.Finance_Expert);
			}
			if (IsDefined("arguments.Tax_Expert")) {
				local.obj.setTax_Expert(arguments.Tax_Expert);
			}
			if (IsDefined("arguments.Outreach_Expert")) {
				local.obj.setOutreach_Expert(arguments.Outreach_Expert);
			}
			if (IsDefined("arguments.AB540_Expert")) {
				local.obj.setAB540_Expert(arguments.AB540_Expert);
			}
			if (IsDefined("arguments.Technology_Expert")) {
				local.obj.setTechnology_Expert(arguments.Technology_Expert);
			}
			if (IsDefined("arguments.Translator")) {
				local.obj.setTranslator(arguments.Translator);
			}
			if (IsDefined("arguments.Translator_Languages")) {
				local.obj.setTranslator_Languages(arguments.Translator_Languages);
			}
			if (IsDefined("arguments.Student")) {
				local.obj.setStudent(arguments.Student);
			}
			if (IsDefined("arguments.Shirt_Size")) {
				local.obj.setShirt_Size(arguments.Shirt_Size);
			}
			if (IsDefined("arguments.Date_Created")) {
				local.obj.setDate_Created(arguments.Date_Created);
			}
			return local.obj;
		</cfscript>
	</cffunction>

	<cffunction name="read" access="public" output="false" returntype="any">
		<cfargument name="Volunteer_ID" required="false" default="" />
		<cfargument name="Deleted" required="false" default="0" />
		<cfargument name="Organization_ID" required="false" default="" />
		<cfargument name="Pool" required="false" default="" />
		<cfargument name="First_Name" required="false" default="" />
		<cfargument name="Last_Name" required="false" default="" />
		<cfargument name="Title" required="false" default="" />
		<cfargument name="Organization" required="false" default="" />
		<cfargument name="Address" required="false" default="" />
		<cfargument name="City" required="false" default="" />
		<cfargument name="Zip_Code" required="false" default="" />
		<cfargument name="County_ID" required="false" default="" />
		<cfargument name="Phone" required="false" default="" />
		<cfargument name="Extension" required="false" default="" />
		<cfargument name="Email" required="false" default="" />
		<cfargument name="Travel_Distance" required="false" default="" />
		<cfargument name="Financial_Aid_Expert" required="false" default="" />
		<cfargument name="FAFSA_Expert" required="false" default="" />
		<cfargument name="Finance_Expert" required="false" default="" />
		<cfargument name="Tax_Expert" required="false" default="" />
		<cfargument name="Outreach_Expert" required="false" default="" />
		<cfargument name="AB540_Expert" required="false" default="" />
		<cfargument name="Technology_Expert" required="false" default="" />
		<cfargument name="Translator" required="false" default="" />
		<cfargument name="Translator_Languages" required="false" default="" />
		<cfargument name="Student" required="false" default="" />
		<cfargument name="Shirt_Size" required="false" default="" />
		<cfargument name="Date_Created" required="false" default="" />
		<cfargument name="volunteerIDs" required="false" default="" />
		<cfargument name="workshopIDs" required="false" default="" />
		<cfargument name="organizationIDs" required="false" default="" />
		<cfargument name="countyIDs" required="false" default="" />
		<cfargument name="regionIDs" required="false" default="" />

		<cfset var recs = "">
		<cfstoredproc datasource="#getDatasource()#" procedure="readVolunteer">
			<cfprocparam value="#arguments.Volunteer_ID#" cfsqltype="CF_SQL_INTEGER" null="#IIf(Len(Trim(arguments.Volunteer_ID)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Deleted#" cfsqltype="CF_SQL_BIT" null="#IIf(Len(Trim(arguments.Deleted)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Organization_ID#" cfsqltype="CF_SQL_INTEGER" null="#IIf(Len(Trim(arguments.Organization_ID)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Pool#" cfsqltype="CF_SQL_BIT" null="#IIf(Len(Trim(arguments.Pool)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.First_Name#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.First_Name)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Last_Name#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.Last_Name)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Title#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.Title)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Organization#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.Organization)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Address#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.Address)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.City#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.City)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Zip_Code#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.Zip_Code)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.County_ID#" cfsqltype="CF_SQL_INTEGER" null="#IIf(Len(Trim(arguments.County_ID)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Phone#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.Phone)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Extension#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.Extension)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Email#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.Email)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Travel_Distance#" cfsqltype="CF_SQL_INTEGER" null="#IIf(Len(Trim(arguments.Travel_Distance)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Financial_Aid_Expert#" cfsqltype="CF_SQL_BIT" null="#IIf(Len(Trim(arguments.Financial_Aid_Expert)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.FAFSA_Expert#" cfsqltype="CF_SQL_BIT" null="#IIf(Len(Trim(arguments.FAFSA_Expert)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Finance_Expert#" cfsqltype="CF_SQL_BIT" null="#IIf(Len(Trim(arguments.Finance_Expert)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Tax_Expert#" cfsqltype="CF_SQL_BIT" null="#IIf(Len(Trim(arguments.Tax_Expert)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Outreach_Expert#" cfsqltype="CF_SQL_BIT" null="#IIf(Len(Trim(arguments.Outreach_Expert)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.AB540_Expert#" cfsqltype="CF_SQL_BIT" null="#IIf(Len(Trim(arguments.AB540_Expert)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Technology_Expert#" cfsqltype="CF_SQL_BIT" null="#IIf(Len(Trim(arguments.Technology_Expert)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Translator#" cfsqltype="CF_SQL_BIT" null="#IIf(Len(Trim(arguments.Translator)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Translator_Languages#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.Translator_Languages)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Student#" cfsqltype="CF_SQL_BIT" null="#IIf(Len(Trim(arguments.Student)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Shirt_Size#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.Shirt_Size)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Date_Created#" cfsqltype="CF_SQL_TIMESTAMP" null="#IIf(Len(Trim(arguments.Date_Created)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.volunteerIDs#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.volunteerIDs)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.workshopIDs#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.workshopIDs)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.organizationIDs#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.organizationIDs)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.countyIDs#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.countyIDs)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.regionIDs#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.regionIDs)) eq 0, true, false)#" />
			<cfprocresult name="recs" />
		</cfstoredproc>
		<cfreturn recs />
	</cffunction>

	<cffunction name="save" access="public" output="false" returntype="any">
		<cfargument name="volunteer" required="true" type="assets.calgrants.com.bo.Volunteer" />

		<cfstoredproc datasource="#getDatasource()#" procedure="saveVolunteer">
			<cfprocparam value="#volunteer.getVolunteer_ID()#" cfsqltype="CF_SQL_INTEGER" variable="id" type="inout" null="false" />
			<cfprocparam value="#volunteer.getDeleted()#" cfsqltype="CF_SQL_BIT" null="false" />
			<cfprocparam value="#volunteer.getOrganization_ID()#" cfsqltype="CF_SQL_INTEGER" null="false" />
			<cfprocparam value="#volunteer.getPool()#" cfsqltype="CF_SQL_BIT" null="false" />
			<cfprocparam value="#volunteer.getFirst_Name()#" cfsqltype="CF_SQL_VARCHAR" null="false" />
			<cfprocparam value="#volunteer.getLast_Name()#" cfsqltype="CF_SQL_VARCHAR" null="false" />
			<cfprocparam value="#volunteer.getTitle()#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(volunteer.getTitle())) eq 0, true, false)#" />
			<cfprocparam value="#volunteer.getOrganization()#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(volunteer.getOrganization())) eq 0, true, false)#" />
			<cfprocparam value="#volunteer.getAddress()#" cfsqltype="CF_SQL_VARCHAR" null="false" />
			<cfprocparam value="#volunteer.getCity()#" cfsqltype="CF_SQL_VARCHAR" null="false" />
			<cfprocparam value="#volunteer.getZip_Code()#" cfsqltype="CF_SQL_VARCHAR" null="false" />
			<cfprocparam value="#volunteer.getCounty_ID()#" cfsqltype="CF_SQL_INTEGER" null="false" />
			<cfprocparam value="#volunteer.getPhone()#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(volunteer.getPhone())) eq 0, true, false)#" />
			<cfprocparam value="#volunteer.getExtension()#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(volunteer.getExtension())) eq 0, true, false)#" />
			<cfprocparam value="#volunteer.getEmail()#" cfsqltype="CF_SQL_VARCHAR" null="false" />
			<cfprocparam value="#volunteer.getTravel_Distance()#" cfsqltype="CF_SQL_INTEGER" null="false" />
			<cfprocparam value="#volunteer.getFinancial_Aid_Expert()#" cfsqltype="CF_SQL_BIT" null="false" />
			<cfprocparam value="#volunteer.getFAFSA_Expert()#" cfsqltype="CF_SQL_BIT" null="false" />
			<cfprocparam value="#volunteer.getFinance_Expert()#" cfsqltype="CF_SQL_BIT" null="false" />
			<cfprocparam value="#volunteer.getTax_Expert()#" cfsqltype="CF_SQL_BIT" null="false" />
			<cfprocparam value="#volunteer.getOutreach_Expert()#" cfsqltype="CF_SQL_BIT" null="false" />
			<cfprocparam value="#volunteer.getAB540_Expert()#" cfsqltype="CF_SQL_BIT" null="false" />
			<cfprocparam value="#volunteer.getTechnology_Expert()#" cfsqltype="CF_SQL_BIT" null="false" />
			<cfprocparam value="#volunteer.getTranslator()#" cfsqltype="CF_SQL_BIT" null="false" />
			<cfprocparam value="#volunteer.getTranslator_Languages()#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(volunteer.getTranslator_Languages())) eq 0, true, false)#" />
			<cfprocparam value="#volunteer.getStudent()#" cfsqltype="CF_SQL_BIT" null="false" />
			<cfprocparam value="#volunteer.getShirt_Size()#" cfsqltype="CF_SQL_VARCHAR" null="false" />
		</cfstoredproc>
		<cfreturn id />
	</cffunction>

	<cffunction name="destroy" access="public" output="false" returntype="any">
		<cfargument name="Volunteer_ID" required="true" />

		<cfstoredproc datasource="#getDatasource()#" procedure="destroyVolunteer">
			<cfprocparam value="#arguments.Volunteer_ID#" cfsqltype="CF_SQL_INTEGER" null="false" />
			<cfprocparam value="true" cfsqltype="CF_SQL_BIT" null="false" />
		</cfstoredproc>
		<cfreturn true />
	</cffunction>

</cfcomponent>

